﻿using JNPF.Basics.Models;
using JNPF.Utils;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;

namespace JNPF.Basics.Logic
{
    /// <summary>
    /// 数据管理
    /// 版 本：V3.0.0
    /// 版 权：引迈信息技术有限公司（https://www.jnpfsoft.com）
    /// 作 者：JNPF开发平台组
    /// 日 期：2018.02.03
    /// </summary>
    internal interface DatabaseIService
    {
        /// <summary>
        /// 表列表
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <returns></returns>
        Task<List<DbTableModel>> GetList(DbLinkEntity link);
        /// <summary>
        /// 表字段
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="table">表名</param>
        /// <returns></returns>
        Task<List<DbTableFieldModel>> GetFieldList(DbLinkEntity link, string table);
        /// <summary>
        /// 表字段
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="table">表名</param>
        /// <returns></returns>
        List<DbTableFieldModel> GetFieldListByNoAsync(DbLinkEntity link, string table);
        /// <summary>
        /// 表数据
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="table">表名</param>
        /// <param name="requestParam">请求参数</param>
        /// <returns></returns>
        Task<PageResult> GetData(DbLinkEntity link, string table, PageInput input);
        /// <summary>
        /// 执行SQL
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="strSql">sql语句</param>
        /// <returns></returns>
        Task<int> ExecuteSql(DbLinkEntity link, string strSql);
        /// <summary>
        /// 删除表
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="table">表名</param>
        Task Delete(DbLinkEntity link, string table);
        /// <summary>
        /// 创建表
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="tableModel">表对象</param>
        /// <param name="tableFieldList">字段对象</param>
        Task Create(DbLinkEntity link, DbTableModel tableModel, List<DbTableFieldModel> tableFieldList);
        /// <summary>
        /// 修改表
        /// </summary>
        /// <param name="link">数据连接</param>
        /// <param name="id">主键值</param>
        /// <param name="tableModel">表对象</param>
        /// <param name="tableFieldList">字段对象</param>
        Task Update(DbLinkEntity link, string id, DbTableModel tableModel, List<DbTableFieldModel> tableFieldList);

        /// <summary>
        /// 根据链接获取数据
        /// </summary>
        /// <returns></returns>
        Task<DataTable> GetInterFaceData(DbLinkEntity link, string strSql);
        /// <summary>
        /// 验证数据库连接
        /// </summary>
        /// <param name="link"></param>
        /// <returns></returns>
        Task<bool> IsConnection(DbLinkEntity link);
    }
}
